//package com.example.shiwu;
//
//import android.annotation.SuppressLint;
//import android.content.Context;
//import android.os.Bundle;
//import android.view.View;
//import android.widget.CheckBox;
//import android.widget.ImageView;
//import android.widget.ListView;
//import android.widget.TextView;
//
//import androidx.appcompat.app.AppCompatActivity;
//
//import com.example.shiwu.adapter.CheckAllAdapter;
//import com.example.shiwu.db.dao.DeviceDao;
//import com.example.shiwu.db.model.Device;
//import com.example.shiwu.db.model.Items;
//import com.example.shiwu.db.vo.DeviceVo;
//import com.example.shiwu.manager.DatabaseHelper;
//import com.example.shiwu.service.DeviceService;
//import com.example.shiwu.service.ItemsService;
//import com.scwang.smartrefresh.layout.api.RefreshLayout;
//import com.scwang.smartrefresh.layout.listener.OnLoadMoreListener;
//import com.scwang.smartrefresh.layout.listener.OnRefreshListener;
//
//import java.util.ArrayList;
//import java.util.HashMap;
//import java.util.List;
//import java.util.Map;
//
//public class DeviceListBackActivity extends AppCompatActivity{
//    private RefreshLayout mRefreshLayout;
//    private ListView listView;
//    private CheckBox checkBox;
//    private CheckAllAdapter myAdapter;
//    private DeviceService deviceService;
//    private ItemsService itemsService;
//    private Map<String, Object> showitem;
//    private List<Map<String, Object>> listitem;
//    private ArrayList<Device> deviceLisAll = new ArrayList<Device>();
//
//    private int currentPage = 0;
//    private int pageSize = 2;
//    private int totalSize = 0;
//    public ListView editSb;
//    public TextView title_text,title_seting;
//    public ImageView title_back;
//
//    private boolean checkSta = false;
//    private DatabaseHelper dbHelper;
//    private DeviceDao deviceDao;
//    private Context myContent;
//    private CheckBox device_items_checkbox;
//
//    @SuppressLint("MissingInflatedId")
//    @Override
//    protected void onCreate(Bundle savedInstanceState) {
//
//        super.onCreate(savedInstanceState);
//        setContentView(R.layout.activity_device_list);
//        myContent = this;
//        deviceDao = new DeviceDao();
//        title_back = findViewById(R.id.title_back);
//        title_text = findViewById(R.id.title_text);
//        device_items_checkbox = findViewById(R.id.device_items_checkbox);
//
//        title_text.setText("数据采集记录");
//        //title_seting.setText("全选");
//        deviceService = new DeviceService();
//        itemsService = new ItemsService();
//        listitem = new ArrayList<Map<String, Object>>();
//        Items items = null;
//        try {
//            items = findSelectItem();
//            if(null != items){
//                Device dev = new Device();
//                dev.setItemId(String.valueOf(items.getId()));
//                List<Device> devlis = deviceService.getDevice(dev);
//                if(devlis.size()>0){
//                    device_items_checkbox.setOnClickListener(new  View.OnClickListener(){
//                        @Override
//                        public void onClick(View view) {
//                            if(checkSta){
//                                btnNoList();
//                                //title_seting.setText("全选");
//                            }else{
//                                btnSelectAllList();
//                                //title_seting.setText("全不选");
//                            }
//
//                        }
//                    });
//                }
//
//            }
//        }catch (Exception e){
//            e.printStackTrace();
//        }
//
//
//        title_back.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View view) {
//                DeviceListBackActivity.this.finish();
//            }
//        });
//        //this.addDeviceData();
//        //this.getDeviceData();
//        this.getDeviceLisAll();
//
//        mRefreshLayout = findViewById(R.id.refreshLayout);
//        mRefreshLayout.setOnRefreshListener(new OnRefreshListener() { //下拉刷新
//            @Override
//            public void onRefresh(RefreshLayout refreshlayout) {
//                getItemsDataHeaderPull();
//                refreshlayout.finishRefresh(2000/*,false*/);//传入false表示刷新失败
//            }
//        });
//
//        mRefreshLayout.setOnLoadMoreListener(new OnLoadMoreListener() { //上拉加载更多
//            @Override
//            public void onLoadMore(RefreshLayout refreshlayout) {
//                getItemsDataFooterPull();
//                refreshlayout.finishLoadMore(2000/*,false*/);//传入false表示加载失败
//            }
//        });
////        FloatingActionButton fab = findViewById(R.id.fab);
////        fab.setOnClickListener(new View.OnClickListener() {
////            @Override
////            public void onClick(View view) {
////                Toast.makeText(myContent, "导出成功！", Toast.LENGTH_SHORT).show();
////            }
////        });
//
//        listView = (ListView) findViewById(R.id.device_list_view);
//
//    }
//    private Items findSelectItem(){
//        itemsService = new ItemsService();
//        Items items = new Items();
//        items.setStatus(1);
//        List<Items> lis = itemsService.getItems(items);
//        return lis.get(0);
//    }
//
////    private void addDeviceData(){
////        deviceService = new DeviceService();
////        deviceService.save(new Device("1","sn123",
////                "10","11","12","1","8","24","34","234","23","123",1,
////                "54","756","345","7234","345","67","10","2023-11-23","2023-11-23"));
////    }
//
////    private void getDeviceData(){
////        //List<Device> deviceLis = deviceService.getDeviceList(new Device(),(currentPage*pageSize),pageSize);
////        //List<DeviceVo> deviceLis = getDeviceLisAll();
////        List<Items> itemLisAll = new ArrayList<Items>();
//////        for (int i = 0; i < deviceLis.size(); i++) {
//////            String item_id = deviceLis.get(i).itemId;
//////            if(item_id ==null && !item_id.equals("")){
//////                List<Items> itemLis = itemsService.getItems(new Items(Integer.parseInt(item_id)));
//////                itemLisAll.addAll(itemLis);
//////            }
//////        }
////
////        //List<DeviceVo> deviceLis = deviceService.getDeviceVoList(new DeviceVo(),currentPage,pageSize);
////        List<DeviceVo> deviceVoLis = new ArrayList<DeviceVo>();
////        DeviceVo deviceVo = new DeviceVo();
////        for (int i = 0; i < itemLisAll.size(); i++) {
////            deviceVo.setId(itemLisAll.get(i).getId());
////            deviceVo.setName(itemLisAll.get(i).getName());
////            deviceVo.setLocation(itemLisAll.get(i).getLocation());
////            deviceVo.setOperator(itemLisAll.get(i).getOperator());
////            deviceVo.setCustomerName(itemLisAll.get(i).getCustomerName());
////            deviceVo.setConstructioUnit(itemLisAll.get(i).getConstructioUnit());
////            //deviceVo.setDeviceType(Integer.parseInt(itemLis.get(i).getDeviceType()));
////            deviceVo.setDeviceType(1);
////            deviceVo.setNum(itemLisAll.get(i).getNum());
////            deviceVo.setCreateTime(itemLisAll.get(i).getCreateTime());
////        }
////        deviceVoLis.add(deviceVo);
////        //currentPage = deviceLis.size();
////
////
////        //创建一个simpleAdapter
////        myAdapter = new CheckAllAdapter(getApplicationContext(), deviceLis, R.layout.device_list_item);
////
////        listView = findViewById(R.id.device_list_view);
////        listView.setAdapter(myAdapter);
////
////        List<Device> deviceLisSize = deviceService.getDevice(new Device());
////        totalSize = deviceLisSize.size();
////    }
//
//    public void getDeviceLisAll() {
//        DeviceService deviceService1 = new DeviceService();
//        List<DeviceVo> device = deviceService1.getAll((currentPage*pageSize),pageSize);
//        //创建一个simpleAdapter
//        myAdapter = new CheckAllAdapter(getApplicationContext(), device, R.layout.device_list_item);
//
//        listView = findViewById(R.id.device_list_view);
//        listView.setAdapter(myAdapter);
//        //totalSize = device.size();
//    }
//
//    private void getItemsDataHeaderPull(){
//        listitem = null;
//        listitem = new ArrayList<Map<String, Object>>();
//        deviceService = new DeviceService();
//        List<Device> deviceLis = deviceService.getDevice(new Device());
//
////        for (int i = 0; i < deviceLis.size(); i++) {
////            showitem = new HashMap<String, Object>();
////            showitem.put("deviceType",deviceLis.get(i).getDeviceType());
////            listitem.add(showitem);
////        }
//
//
//        myAdapter.notifyDataSetChanged();
//
//    }
//    private void getItemsDataFooterPull(){
//
//        deviceService = new DeviceService();
//        List<Device> deviceLis = deviceService.getDeviceList(new Device(),(currentPage*pageSize),pageSize);
//
//        for (int i = 0; i < deviceLis.size(); i++) {
//            showitem = new HashMap<String, Object>();
//            showitem.put("deviceType",deviceLis.get(i).getDeviceType());
//            listitem.add(showitem);
//        }
//        currentPage ++;
//
//        myAdapter.notifyDataSetChanged();
//    }
//
//    /**
//     * 全选
//     * @param
//     */
//    public void btnSelectAllList() {
//        int count = listView.getCount();
//        checkBox = findViewById(R.id.device_items_checkbox);
//        checkBox.setChecked(true);
//        checkSta = true;
////        for (int i = 0; i < listitem.size(); i++) {
////            listitem.get(i).get("isCheck") = true;
////        }
//    }
//
//    /**
//     * 全不选
//     * @param
//     */
//    public void btnNoList() {
//
//        checkBox = findViewById(R.id.device_items_checkbox);
//        checkBox.setChecked(false);
//        checkSta = false;
//    }
//
//}